package com.itheima.mapper;

import com.itheima.entity.Clazz;
import com.itheima.entity.ClazzQueryParam;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ClazzMapper {
    @Select("select * from clazz")
    public List<Clazz>list();

    /**
     * 分页查询
     * @param param
     * @return
     */
    List<Clazz> page(ClazzQueryParam param);

    /**
     * 更加ID删除班级
     * @param id
     */
    @Delete("delete from clazz where id=#{id}")
    void deleteByID(Integer id);

    /**
     * 添加班级
     * @param clazz
     */
    @Select("insert into clazz(name,room,begin_date,end_date,master_id,subject,create_time,update_time) values(#{name},#{room},#{beginDate},#{endDate},#{masterId},#{subject},#{createTime},#{updateTime})")
    void add(Clazz clazz);

    /**
     * 根据ID查询班级
     * @param id
     * @return
     */
    @Select("select * from clazz where id = #{id}")
    Clazz getById(Integer id);

    /**
     * 更新班级
     * @param clazz
     */
    void update(Clazz clazz);
}
